using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_Location {
		#region Fields
		private string locCode;
		private string name;
		private string description;
		private string parentLocCode;
		private int languageId;
		private string imageURL;
		private string ipAddressL;
		private string ipAddressH;
		private string fullName;
		private int type;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_Location class.
		/// </summary>
		public TF_Location() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_Location class.
		/// </summary>
		public TF_Location(string locCode, string name, string description, string parentLocCode, int languageId, string imageURL, string ipAddressL, string ipAddressH, string fullName, int type) {
			this.locCode = locCode;
			this.name = name;
			this.description = description;
			this.parentLocCode = parentLocCode;
			this.languageId = languageId;
			this.imageURL = imageURL;
			this.ipAddressL = ipAddressL;
			this.ipAddressH = ipAddressH;
			this.fullName = fullName;
			this.type = type;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the LocCode value.
		/// </summary>
		public string LocCode {
			get { return locCode; }
			set { locCode = value; }
		}
		
		/// <summary>
		/// Gets or sets the Name value.
		/// </summary>
		public string Name {
			get { return name; }
			set { name = value; }
		}
		
		/// <summary>
		/// Gets or sets the Description value.
		/// </summary>
		public string Description {
			get { return description; }
			set { description = value; }
		}
		
		/// <summary>
		/// Gets or sets the ParentLocCode value.
		/// </summary>
		public string ParentLocCode {
			get { return parentLocCode; }
			set { parentLocCode = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanguageId value.
		/// </summary>
		public int LanguageId {
			get { return languageId; }
			set { languageId = value; }
		}
		
		/// <summary>
		/// Gets or sets the ImageURL value.
		/// </summary>
		public string ImageURL {
			get { return imageURL; }
			set { imageURL = value; }
		}
		
		/// <summary>
		/// Gets or sets the IpAddressL value.
		/// </summary>
		public string IpAddressL {
			get { return ipAddressL; }
			set { ipAddressL = value; }
		}
		
		/// <summary>
		/// Gets or sets the IpAddressH value.
		/// </summary>
		public string IpAddressH {
			get { return ipAddressH; }
			set { ipAddressH = value; }
		}
		
		/// <summary>
		/// Gets or sets the FullName value.
		/// </summary>
		public string FullName {
			get { return fullName; }
			set { fullName = value; }
		}
		
		/// <summary>
		/// Gets or sets the Type value.
		/// </summary>
		public int Type {
			get { return type; }
			set { type = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_Location table.
		/// </summary>
		public void Insert() {
			SqlClientUtility.ExecuteNonQuery("TF_LocationInsert", locCode, name, description, parentLocCode, languageId, imageURL, ipAddressL, ipAddressH, fullName, type);
		}
		
		/// <summary>
		/// Selects all records from the TF_Location table.
		/// </summary>
		public static List<TF_Location> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_LocationSelectAll")) {
				List<TF_Location> tF_LocationList = new List<TF_Location>();
				while (dataReader.Read()) {
					TF_Location tF_Location = MakeTF_Location(dataReader);
					tF_LocationList.Add(tF_Location);
				}
				return tF_LocationList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_Location class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_Location MakeTF_Location(SqlDataReader dataReader) {
			TF_Location tF_Location = new TF_Location();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_Location.LocCode = dataReader.GetString(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_Location.Name = dataReader.GetString(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_Location.Description = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_Location.ParentLocCode = dataReader.GetString(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_Location.LanguageId = dataReader.GetInt32(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_Location.ImageURL = dataReader.GetString(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_Location.IpAddressL = dataReader.GetString(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_Location.IpAddressH = dataReader.GetString(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_Location.FullName = dataReader.GetString(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_Location.Type = dataReader.GetInt32(9);
			}

			return tF_Location;
		}
		#endregion
	}
}
